package com.loyal.loyalerp.humenresource.kaoqinMonth.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.loyal.loyalerp.humenresource.kaoqinMonth.mapper.provider.KaoqinMonthProvider;
import com.loyal.loyalerp.humenresource.kaoqinMonth.model.RsKaoqinmonth;
import com.loyal.loyalerp.humenresource.kaoqinMonth.model.RsKaoqinmonthExample;
import com.loyal.loyalerp.model.vo.CompanyIdAndYears;

@Mapper
public interface RsKaoqinmonthMapper {
	
	@SelectProvider(type=KaoqinMonthProvider.class,method="getKmByCY")
	List<RsKaoqinmonth> getKmByCY(int companyId,int year);
		
	@SelectProvider(type=KaoqinMonthProvider.class,method="findKm")
	List<RsKaoqinmonth> findKm(String searchField, String searchString);
	
	@Select("select mCloseFlag from rs_kaoqinmonth where comopanyId=#{comopanyid} and year=#{year} and month=#{month}")
	int selectCloseFlag(RsKaoqinmonth km);
	
	@Insert("insert into rs_kaoqinmonth (comopanyId,year,month,mCloseFlag) values (#{comopanyid},#{year},#{month},1)")
	void insertPreviousYear(RsKaoqinmonth km);
	
	@UpdateProvider(type=KaoqinMonthProvider.class,method="updateCloseFlag")
	int updateCloseFlag(int id,int closeFlag);
	
	@SelectProvider(type=KaoqinMonthProvider.class,method="getKmByYMC")
	RsKaoqinmonth getKmByYMC(RsKaoqinmonth record);
	
	//查询所有所有信息
	@SelectProvider(type=KaoqinMonthProvider.class,method="listKaoqinMonth")
	List<RsKaoqinmonth> listSortedKaoqinMonth(String sidx,String sord);
	
	//根据companyid+year+month查询记录
	@SelectProvider(type=KaoqinMonthProvider.class,method="selectByCY")
	int selectByCY(RsKaoqinmonth km);
	
    int countByExample(RsKaoqinmonthExample example);

    int deleteByExample(RsKaoqinmonthExample example);

    int deleteByPrimaryKey(Integer id);

    @InsertProvider(type=KaoqinMonthProvider.class,method="insertKaoqinMonth")
    int insert(RsKaoqinmonth record);

    int insertSelective(RsKaoqinmonth record);

    List<RsKaoqinmonth> selectByExample(RsKaoqinmonthExample example);

    RsKaoqinmonth selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") RsKaoqinmonth record, @Param("example") RsKaoqinmonthExample example);

    int updateByExample(@Param("record") RsKaoqinmonth record, @Param("example") RsKaoqinmonthExample example);

    int updateByPrimaryKeySelective(RsKaoqinmonth record);

    int updateByPrimaryKey(RsKaoqinmonth record);
    
    int selectLastYearHasEnd(CompanyIdAndYears cmd);
}